using System;
using System.Collections.Generic;
using Millel.Software.Examples.Common.Entities;
using Millel.Software.Examples.Linq.Entities;
using System.Linq;

namespace Millel.Software.Examples.Linq.Examples
{
    public class Where : AbstractExample
    {
        public override void Run()
        {
            var tieFighters = new List<TieFigher>
                                  {
                                      new TieFigher {Pilot = "Darth Vader"},
                                      new TieFigher {Pilot = "Darth Maul"}
                                  };

            Console.WriteLine("Using sql like syntax");

            var pilots = from tieFighter in tieFighters where tieFighter.Pilot == "Darth Maul" select tieFighter;
            pilots.ToList().ForEach(n => Console.WriteLine(n.Pilot));

            Console.WriteLine("Using extension method");

            pilots = tieFighters.Where(n => n.Pilot == "Darth Vader");
            pilots.ToList().ForEach(n => Console.WriteLine(n.Pilot));

            Console.WriteLine("Where example complete - press any key to continue");
            Console.ReadLine();
        }
    }
}